package Count;

import java.util.Scanner;
import java.util.regex.Pattern;

public class CountApi {

    //统计一个函数中api个数
    public int CountApi(String str){
        int result =0 ;
        Scanner sc = new Scanner(str);
        String temp;
        boolean isletter;

        while(sc.hasNextLine()){
            temp = sc.nextLine();
            isletter = Pattern.compile("(?i)[a-z]").matcher(temp).find();   //正则表达式匹配判断是否含有字母
            if (isletter){
                if(temp.contains("new")){
                    result++;
                }else if (temp.contains(".")){
                    if(!temp.contains("this.") && !temp.contains("super.") && !temp.contains("out.")){
                        result++;
                    }
                }else{

                }
            }
        }
        return result;
    }
}
